package com.mrbus.zip;

import org.apache.commons.compress.parallel.InputStreamSupplier;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * 多线程输入流 <br>
 * date：2020-12-26 13:57
 *
 * @author MrBUS
 * @version 1.0
 * @since JDK 1.8
 */
public class ZipArchiveInputStreamSupplier implements InputStreamSupplier {

    private final File file;

    public ZipArchiveInputStreamSupplier(File file) {
        this.file = file;
    }

    @Override
    public InputStream get() {
        try {
            return file.isDirectory() ? new ZipArchiveNullInputStream(0) : new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}